<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Using Google Documents List Data API - Zend Framework Manual</title>

    <link href="../css/shCore.css" rel="stylesheet" type="text/css" />
    <link href="../css/shThemeDefault.css" rel="stylesheet" type="text/css" />
    <link href="../css/styles.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Zend Framework</h1>
<h2>Programmer's Reference Guide</h2>
<ul>
    <li><a href="../en/zend.gdata.docs.html">Inglês (English)</a></li>
    <li><a href="../pt-br/zend.gdata.docs.html">Português Brasileiro (Brazilian Portuguese)</a></li>
</ul>
<table width="100%">
    <tr valign="top">
        <td width="85%">
            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.gdata.calendar.html">Using Google Calendar</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.gdata.html">Zend_Gdata</a></span><br />
                        <span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.gdata.health.html">Using Google Health</a></div>
                    </td>
                </tr>
            </table>
<hr />
<div id="zend.gdata.docs" class="section"><div class="info"><h1 class="title">Using Google Documents List Data API</h1></div>
    

    <p class="para">
        The Google Documents List Data <acronym class="acronym">API</acronym> allows client applications to
        upload documents to Google Documents and list them in the form of
        Google Data <acronym class="acronym">API</acronym> (&quot;GData&quot;) feeds. Your client application can request
        a list of a user&#039;s documents, and query the content in an existing
        document.
    </p>

    <p class="para">
        See <a href="http://code.google.com/apis/documents/overview.html" class="link external">&raquo; http://code.google.com/apis/documents/overview.html</a>
        for more information about the Google Documents List <acronym class="acronym">API</acronym>.
    </p>

    <div class="section" id="zend.gdata.docs.listdocuments"><div class="info"><h1 class="title">Get a List of Documents</h1></div>
        

        <p class="para">
            You can get a list of the Google Documents for a particular user by using
            the  <span class="methodname">getDocumentListFeed()</span> method of the docs
            service. The service will return a
            <span class="classname">Zend_Gdata_Docs_DocumentListFeed</span> object
            containing a list of documents associated with the authenticated
            user.
        </p>

        <pre class="programlisting brush: php">
$service = Zend_Gdata_Docs::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$docs = new Zend_Gdata_Docs($client);
$feed = $docs-&gt;getDocumentListFeed();
</pre>


        <p class="para">
        The resulting <span class="classname">Zend_Gdata_Docs_DocumentListFeed</span> object
        represents the response from the server. This feed contains a list of
        <span class="classname">Zend_Gdata_Docs_DocumentListEntry</span> objects
        (<strong class="command">$feed-&gt;entries</strong>), each of which represents a single
        Google Document.
        </p>
    </div>

    <div class="section" id="zend.gdata.docs.creating"><div class="info"><h1 class="title">Upload a Document</h1></div>
        

        <p class="para">
            You can create a new Google Document by uploading a word
            processing document, spreadsheet, or presentation. This example
            is from the interactive Docs.php sample which comes with the
            library. It demonstrates uploading a file and printing
            information about the result from the server.
        </p>

        <pre class="programlisting brush: php">
/**
 * Upload the specified document
 *
 * @param Zend_Gdata_Docs $docs The service object to use for communicating
 *     with the Google Documents server.
 * @param boolean $html True if output should be formatted for display in a
 *     web browser.
 * @param string $originalFileName The name of the file to be uploaded. The
 *     MIME type of the file is determined from the extension on this file
 *     name. For example, test.csv is uploaded as a comma separated volume
 *     and converted into a spreadsheet.
 * @param string $temporaryFileLocation (optional) The file in which the
 *     data for the document is stored. This is used when the file has been
 *     uploaded from the client&#039;s machine to the server and is stored in
 *     a temporary file which does not have an extension. If this parameter
 *     is null, the file is read from the originalFileName.
 */
function uploadDocument($docs, $html, $originalFileName,
                        $temporaryFileLocation) {
  $fileToUpload = $originalFileName;
  if ($temporaryFileLocation) {
    $fileToUpload = $temporaryFileLocation;
  }

  // Upload the file and convert it into a Google Document. The original
  // file name is used as the title of the document and the MIME type
  // is determined based on the extension on the original file name.
  $newDocumentEntry = $docs-&gt;uploadFile($fileToUpload, $originalFileName,
      null, Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI);

  echo &quot;New Document Title: &quot;;

  if ($html) {
      // Find the URL of the HTML view of this document.
      $alternateLink = &#039;&#039;;
      foreach ($newDocumentEntry-&gt;link as $link) {
          if ($link-&gt;getRel() === &#039;alternate&#039;) {
              $alternateLink = $link-&gt;getHref();
          }
      }
      // Make the title link to the document on docs.google.com.
      echo &quot;&lt;a href=\&quot;$alternateLink\&quot;&gt;\n&quot;;
  }
  echo $newDocumentEntry-&gt;title.&quot;\n&quot;;
  if ($html) {echo &quot;&lt;/a&gt;\n&quot;;}
}
</pre>

    </div>

    <div class="section" id="zend.gdata.docs.queries"><div class="info"><h1 class="title">Searching the documents feed</h1></div>
        

        <p class="para">
            You can search the Document List using some of the <a href="http://code.google.com/apis/gdata/reference.html#Queries" class="link external">&raquo; standard
            Google Data <acronym class="acronym">API</acronym> query parameters</a>. Categories are used to
            restrict the
            type of document (word processor document, spreadsheet) returned.
            The full-text query string is used to search the content of all
            the documents. More detailed information on parameters specific
            to the Documents List can be found in the <a href="http://code.google.com/apis/documents/reference.html#Parameters" class="link external">&raquo; Documents List
                Data <acronym class="acronym">API</acronym> Reference Guide</a>.
        </p>

        <div class="section" id="zend.gdata.docs.listwpdocuments"><div class="info"><h1 class="title">Get a List of Word Processing Documents</h1></div>
            

            <p class="para">
                You can also request a feed containing all of your documents of a specific type. For
                example, to see a list of your work processing documents, you would perform a
                category query as follows.
            </p>

            <pre class="programlisting brush: php">
$feed = $docs-&gt;getDocumentListFeed(
    &#039;http://docs.google.com/feeds/documents/private/full/-/document&#039;);
</pre>

        </div>

        <div class="section" id="zend.gdata.docs.listspreadsheets"><div class="info"><h1 class="title">Get a List of Spreadsheets</h1></div>
            

            <p class="para">
                To request a list of your Google Spreadsheets, use the following category query:
            </p>

            <pre class="programlisting brush: php">
$feed = $docs-&gt;getDocumentListFeed(
    &#039;http://docs.google.com/feeds/documents/private/full/-/spreadsheet&#039;);
</pre>

        </div>

        <div class="section" id="zend.gdata.docs.textquery"><div class="info"><h1 class="title">Performing a text query</h1></div>
            

            <p class="para">
                You can search the content of documents by using a
                <span class="classname">Zend_Gdata_Docs_Query</span> in your request. A Query object
                can be used to construct the query <acronym class="acronym">URI</acronym>, with the search term
                being passed in as a parameter. Here is an example method which queries
                the documents list for documents which contain the search string:
            </p>

            <pre class="programlisting brush: php">
$docsQuery = new Zend_Gdata_Docs_Query();
$docsQuery-&gt;setQuery($query);
$feed = $client-&gt;getDocumentListFeed($docsQuery);
</pre>

        </div>
    </div>
</div>
        <hr />

            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.gdata.calendar.html">Using Google Calendar</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.gdata.html">Zend_Gdata</a></span><br />
                        <span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.gdata.health.html">Using Google Health</a></div>
                    </td>
                </tr>
            </table>
</td>
        <td style="font-size: smaller;" width="15%"> <style type="text/css">
#leftbar {
	float: left;
	width: 186px;
	padding: 5px;
	font-size: smaller;
}
ul.toc {
	margin: 0px 5px 5px 5px;
	padding: 0px;
}
ul.toc li {
	font-size: 85%;
	margin: 1px 0 1px 1px;
	padding: 1px 0 1px 11px;
	list-style-type: none;
	background-repeat: no-repeat;
	background-position: center left;
}
ul.toc li.header {
	font-size: 115%;
	padding: 5px 0px 5px 11px;
	border-bottom: 1px solid #cccccc;
	margin-bottom: 5px;
}
ul.toc li.active {
	font-weight: bold;
}
ul.toc li a {
	text-decoration: none;
}
ul.toc li a:hover {
	text-decoration: underline;
}
</style>
 <ul class="toc">
  <li class="header home"><a href="manual.html">Programmer's Reference Guide</a></li>
  <li class="header up"><a href="manual.html">Programmer's Reference Guide</a></li>
  <li class="header up"><a href="reference.html">Zend Framework Reference</a></li>
  <li class="header up"><a href="zend.gdata.html">Zend_Gdata</a></li>
  <li><a href="zend.gdata.introduction.html">Introduction</a></li>
  <li><a href="zend.gdata.authsub.html">Authenticating with AuthSub</a></li>
  <li><a href="zend.gdata.books.html">Using the Book Search Data API</a></li>
  <li><a href="zend.gdata.clientlogin.html">Authenticating with ClientLogin</a></li>
  <li><a href="zend.gdata.calendar.html">Using Google Calendar</a></li>
  <li class="active"><a href="zend.gdata.docs.html">Using Google Documents List Data API</a></li>
  <li><a href="zend.gdata.health.html">Using Google Health</a></li>
  <li><a href="zend.gdata.spreadsheets.html">Using Google Spreadsheets</a></li>
  <li><a href="zend.gdata.gapps.html">Using Google Apps Provisioning</a></li>
  <li><a href="zend.gdata.gbase.html">Using Google Base</a></li>
  <li><a href="zend.gdata.photos.html">Using Picasa Web Albums</a></li>
  <li><a href="zend.gdata.youtube.html">Using the YouTube Data API</a></li>
  <li><a href="zend.gdata.exception.html">Catching Gdata Exceptions</a></li>
 </ul>
 </td>
    </tr>
</table>

<script type="text/javascript" src="../js/shCore.js"></script>
<script type="text/javascript" src="../js/shAutoloader.js"></script>
<script type="text/javascript" src="../js/main.js"></script>

</body>
</html>